﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Manage_newsList : System.Web.UI.Page
{
    BLL.NewsBll nb = new BLL.NewsBll();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    private void BindData()
    {
        DataTable table = nb.GetNewsAll2();
        grd_News.DataSource = table;
        grd_News.DataBind();
    }

    protected void grd_News_SelectedIndexChanged(object sender, EventArgs e)
    {
        int id = int.Parse(grd_News.Rows[grd_News.SelectedIndex].Cells[0].Text.ToString());
        Response.Redirect("newsAdd.aspx?id="+id);
    }
    protected void grd_News_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        int id = int.Parse(grd_News.Rows[e.RowIndex].Cells[0].Text.ToString());
        nb.DeleteNewsContent(id);
        BindData();
    }
}
